package cn.iocoder.yudao.module.bpm.dal.mysql.formdata;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.bpm.dal.dataobject.formdata.FormDataDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.bpm.controller.admin.formdata.vo.*;

/**
 * 表单详情 Mapper
 *
 * @author admin
 */
@Mapper
public interface FormDataMapper extends BaseMapperX<FormDataDO> {

    default PageResult<FormDataDO> selectPage(FormDataPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FormDataDO>()
                .eqIfPresent(FormDataDO::getSort, reqVO.getSort())
                .likeIfPresent(FormDataDO::getFieldName, reqVO.getFieldName())
                .eqIfPresent(FormDataDO::getFieldDef, reqVO.getFieldDef())
                .eqIfPresent(FormDataDO::getConfig, reqVO.getConfig())
                .eqIfPresent(FormDataDO::getFormDef, reqVO.getFormDef())
                .eqIfPresent(FormDataDO::getStatus, reqVO.getStatus())
                .eqIfPresent(FormDataDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(FormDataDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FormDataDO::getId));
    }

    default List<FormDataDO> selectList(FormDataExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FormDataDO>()
                .eqIfPresent(FormDataDO::getSort, reqVO.getSort())
                .likeIfPresent(FormDataDO::getFieldName, reqVO.getFieldName())
                .eqIfPresent(FormDataDO::getFieldDef, reqVO.getFieldDef())
                .eqIfPresent(FormDataDO::getConfig, reqVO.getConfig())
                .eqIfPresent(FormDataDO::getFormDef, reqVO.getFormDef())
                .eqIfPresent(FormDataDO::getStatus, reqVO.getStatus())
                .eqIfPresent(FormDataDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(FormDataDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FormDataDO::getId));
    }

    int deleteByFormdef(String formDef);
}
